<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <h1>The Ajax 02 Page</h1>
    <fieldset>
        <legend>Ajax 表单请求</legend>
        <form>
        <input type=text" onblur="doCheck()" name="name" id="nameId" onfocus="doClear()">
        <button type="button" onclick="doSave()">Save</button>
        </form>
        <span id="result"></span>
    </fieldset>

</div>
</body>
<script>
    function doClear(){
        document.getElementById("result").innerHTML="";
    }
    function doSave(){
        var xhr=new XMLHttpRequest();
        xhr.onreadystatechange=function (){
            if(xhr.readyState==4&&xhr.status==200){
                console.log(xhr.responseText);
                document.getElementById("result").innerHTML=xhr.responseText;
            }
        };
        var name=document.forms[0].name.value;
        xhr.open("POST","http://localhost:1314/doSave",true);
        xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        xhr.send("name="+name);
        console.log("do other....");
    }
    function doCheck(){
        var xhr=new XMLHttpRequest();
        xhr.onreadystatechange=function (){
            if (xhr.readyState==4&&xhr.status==200){
                document.getElementById("result").innerHTML=xhr.responseText;
            }
        }
        debugger;
        var name=document.forms[0].name.value;
        console.log("name",name);
        xhr.open("GET","http://localhost:1314/doCheck?name="+name,true);
        xhr.send();
        xhr.
    }

</script>
</html>